<template>
  <div class="index">
    <div class="top_advertisement">
      <img src="https://av.wuyoufang.com/uploads/20180905/d9bd3df27d31426ee27423d0db0e504e.png" alt="">
    </div>
    <!--搜索-->
    <div>
      <search-top></search-top>
    </div>
    <div class="content">
      <!--轮播图-->
      <div class="swipe">
        <index-swipe></index-swipe>
      </div>
      <!--菜单/模块-->
      <div class="menu">
        <menu-logo></menu-logo>
      </div>
      <!--资讯-->
      <div class="zixun">
        <building-information></building-information>
      </div>
      <!--快捷找房-->
      <div class="kuaijie">
        <quick-search></quick-search>
      </div>
      <!--热播视频-->
      <!--<div class="hot_video">-->
        <!--<keep-alive>-->
          <!--<hot-video></hot-video>-->
        <!--</keep-alive>-->
      <!--</div>-->
      <!--品牌房企-->
      <!--<div class="hot_video">-->
      <!--<brand-house></brand-house>-->
      <!--</div>-->
      <!--为您精选-->
      <div class="loupan_tuijian">
        <building-recommend></building-recommend>
      </div>
      <!--金牌经纪人-->
      <!--<div class="hot_video">-->
        <!--<gold-medal></gold-medal>-->
      <!--</div>-->
      <!--装修精选-->
      <!--<div class="hot_video">-->
      <!--<recommended-designer></recommended-designer>-->
      <!--</div>-->
      <!--推荐施工队-->
      <!--<div class="hot_video">-->
      <!--<construction-corps></construction-corps>-->
      <!--</div>-->
      <!--我要装修 买房 租房-->
      <div class="zhuangxiu_sheji">
        <find-designer></find-designer>
        <!--<div id="box">-->

        <!--</div>-->
      </div>
    </div>
    <!--导航栏-->
    <div>
      <tab-bar :selected="selected"></tab-bar>
    </div>

    <!--<div @click="getTestShow">测试猜测打电脑活塞的红包UIif还是姐夫好声音的风格</div>-->
  </div>
</template>

<script>
  import TabBar from '../../components/common/TabBar';
  import SearchTop from '../../components/common/Search';
  import MenuLogo from '../../components/Menu';
  // import HotVideo from '../../components/HotVideo';
  import {getCityName, setCityName} from '../../assets/js/cache';
  // import BrandHouse from '../../components/BrandHouse';
  import IndexSwipe from '../../components/IndexSwipe';
  import BuildingInformation from '../../components/BuildingInformation';
  import BuildingRecommend from '../../components/BuildingRecommend';
  // import GoldMedal from '../../components/GoldMedal';
  // import RecommendedDesigner from '../../components/decorationComm/RecommendedDesigner';
  import QuickSearch from '../../components/QuickSearch';
  // import ConstructionCorps from '../../components/ConstructionCorps';
  import FindDesigner from '../../components/indexCommon/FindDesigner';
  // import alert from '../../store/modules/alert';
  import {setLatitude, setLongitude} from '../../assets/js/cache';

  export default {
    name: 'Index',
    data() {
      return {
        selected: 'Index'
      }
    },
    computed: {
      getRouterName() {
        return this.$store.getters.getRouterName;
      }
    },
    beforeRouteEnter(to, from, next) {
        from.meta.keepAlive = true;
      next();
    },
    watch: {
      $route(to, from) {
        // if (to.name === 'LookBuild' || to.name === 'TwoHouse'){
        //   to.meta.keepAlive = false;
        // }
      }
    },
    beforeRouteLeave(to, from, next) {
      console.log(to.name,'------');
      // 设置下一个路由的 meta
      // || to.name !== 'LookBuild'
      if (to.name !== 'AllVideo'){
        if (this.getRouterName === 'CityIndex') {
          to.meta.keepAlive = false;
        }
      }
      this.$store.commit('setRouterName',this.$route.name);
      this.$store.commit('setFindRouterName',this.$route.name);

      next();
    },

    methods: {
      getTestShow() {
        window.navigator.geolocation.getCurrentPosition(position => {
          setLatitude(position.coords.latitude);
          setLongitude(position.coords.longitude);

        })
      }
    },


    components: {
      FindDesigner,
      QuickSearch,
      IndexSwipe,
      TabBar,
      SearchTop,
      MenuLogo,
      // HotVideo,
      // BrandHouse,
      BuildingInformation,
      BuildingRecommend,
      // GoldMedal,
      // RecommendedDesigner,
      // ConstructionCorps
    },
    mounted() {

    },
    created() {
      this.getTestShow();
      if (getCityName() === undefined) {
        this.cityName = {CODE: '4601', region_name_c: '海口市', region_name_e: 'H'};
        setCityName(this.cityName);

      } else {
        this.cityName = getCityName();
      }
    }

  }
</script>

<style scoped>
  .index {
    background-color: #fff;
    padding-bottom: 55px;
  }

  .index .top_advertisement {
    height: 2rem;
    padding: 10px;
    text-align: center;
  }

  .index .top_advertisement img {
    height: 100%;
  }

  .swipe {
    height: calc(9rem + 20px);
    padding-bottom: 10px;
    border-radius: 40%;
  }

  .hot_video {
    border-top: 10px solid #eee;
    padding: 10px;
  }

  .zhuangxiu_sheji {
    border-top: 10px solid #eee;
  }

  .loupan_tuijian {
    border-top: 10px solid #eee;
  }

  .kuaijie {
    border-top: 10px solid #eee;
  }
</style>
